
package com.oyo.common.exception;

import com.oyo.common.enums.ResponseCode;

/**
 * 服务层异常
 */
public class ServiceException extends RuntimeException {

    private static final long serialVersionUID = 1L;
    /**
     * 返回码
     */
    private String code;
    /**
     * 返回信息
     */
    private String msg;

    public ServiceException(String code, String msg) {
        super(code + ":" + msg);
        this.code = code;
        this.msg = msg;
    }

    public ServiceException(String code, String msg, Throwable cause) {
        super(code + ":" + msg, cause);
        this.code = code;
        this.msg = msg;
    }

    public ServiceException(ResponseCode responseCode) {
        super(responseCode.getCode() + ":" + responseCode.getMsg());
        this.code = responseCode.getCode();
        this.msg = responseCode.getMsg();
    }

    public ServiceException(ResponseCode responseCode, Throwable cause) {
        super(responseCode.getCode() + ":" + responseCode.getMsg(), cause);
        this.code = responseCode.getCode();
        this.msg = responseCode.getMsg();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
